<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <form  class="layui-form layuimini-form" lay-filter="formTest" >
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="perf_id" lay-verify="required" placeholder="请输入周考核量" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form layuimini-form">
                <div class="layui-form-item">
                    <label class="layui-form-label required">设置日期</label>
                    <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
                        <input type="text" name="perf_time" class="layui-input" id="test1">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">周考核量</label>
                    <div class="layui-input-block">
                        <input type="text" name="perf_week" lay-verify="required" placeholder="请输入周考核量" value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">月考核量</label>
                    <div class="layui-input-block">
                        <input type="number" name="perf_month" placeholder="请输入月考核量" value="" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        //拿到从页面保存的值
        var data=JSON.parse(localStorage.getItem("pref"));
        //赋值，修改页面
        form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
             "perf_id":data.perf_id
            ,"perf_time": data.perf_time
            ,"perf_week": data.perf_week // "name": "value"
            ,"perf_month": data.perf_month
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {
                // 关闭弹出层
                var iframeIndex = parent.layer.getFrameIndex(window.name);
            });
            $.post("prefupdate",data.field,function(res){
                if(res.code==200){
                    layer.msg('更改成功！');
                    layer.close(index);
                }else{
                    layer.msg('失败：'+res.msg);
                }
            })
            return false;
        });
    });
</script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#test1' //指定元素
        });
    });
</script>
</body>

</html>